package com.dingding.transfer.stamper.service.impl;

import com.dingding.transfer.stamper.dto.BaseResult;
import com.dingding.transfer.stamper.dto.BaseResultFactory;
import com.dingding.transfer.stamper.dto.SealRecordInfoReq;
import com.dingding.transfer.stamper.entity.StampRecord;
import com.dingding.transfer.stamper.service.CmdStrategy;
import lombok.extern.slf4j.Slf4j;

/**
 * @author wangxiyuan
 * @description
 * @createDate 2021/4/7 10:20
 **/
@Slf4j
public class SealRecordInfoReqStrategy implements CmdStrategy {
    @Override
    public BaseResult handle(Object object) {
        log.info("用印记录回调");
        SealRecordInfoReq sealRecordInfoReq = (SealRecordInfoReq) object;
        if(sealRecordInfoReq.getType() == 0){
            StampRecord stampRecord = new StampRecord();
            stampRecord.setMark(sealRecordInfoReq.getMark()).setLocation(sealRecordInfoReq.getAddr())
                    .setUseCount(sealRecordInfoReq.getCount()).setUserName(sealRecordInfoReq.getUserName())
                    .setUseTime(sealRecordInfoReq.getTime()).setUuid(sealRecordInfoReq.getUuid())
                    .setStatus(false).setApplyId(sealRecordInfoReq.getApplicationId());
            stampRecord.insert();
        }

        return BaseResultFactory.produceSuccess();
    }
}
